using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using LESLogica;

public partial class cadastroUsuarioTeste : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            this.TabContainer1.ActiveTabIndex = 1;
            SUsuario usuario = (SUsuario)Session["usuarioParaCadastrar"];
        }
        catch (Exception exc)
        {
            Response.Redirect("cadastroUsuarios.aspx");
        }
    }
    protected void CheckBoxOutrosDispositivos_CheckedChanged(object sender, EventArgs e)
    {
        this.TextBoxOutrosDispostivos.Enabled = !(this.TextBoxOutrosDispostivos.Enabled);
    }
    protected void ButtonCadastrar_Click(object sender, EventArgs e)
    {
        this.cadastrar();
    }

    private void cadastrar()
    {
        string nomeUsuario = this.TextBoxNome.Text;
        this.LabelConfirmacao.ForeColor = System.Drawing.Color.Black;
        this.LabelConfirmacao.Text = "Usuario(a) '" + nomeUsuario + "' cadastrado(a) com sucesso";
        FacadeService service = new FacadeService();
        try
        {

            SUsuario usuario = (SUsuario)Session["usuarioParaCadastrar"];
            service.CrieUsuario(usuario.nome, usuario.senha, usuario.tipo);
            service.CrieUsuarioDeTeste(nomeUsuario, System.Convert.ToInt32(this.TextBoxIdade.Text),
                this.DropDownListSexo.SelectedValue, this.TextBoxProfissao.Text, this.DropDownListExperiencia.SelectedValue,
                this.DropDownListFormacao.SelectedValue, "" + this.CheckBoxTeclado.Checked, "" + this.CheckBoxMouse.Checked,
                this.TextBoxOutrosDispostivos.Text, "" + this.CheckBoxLentes.Checked);
        }
        catch (Exception exc)
        {
            this.LabelConfirmacao.ForeColor = System.Drawing.Color.Red;
            this.LabelConfirmacao.Text = exc.Message;
        }
        ApagarTextos.apagar(this);
    }

}
